﻿Imports FM.NetBouncer
Imports System.Configuration

Public Class CustomIsNameFerruh
    Inherits ConfigurationElement
    Implements IRule(Of String)

    Public Sub New()
    End Sub

    Public Function IsValid(ByVal input As String) As Boolean Implements Global.FM.NetBouncer.IRule(Of String).IsValid
        Return input = "ferruh"
    End Function

End Class



''' <summary>
''' Divadable Numbers
''' </summary>
Public Class DividableBy
    Inherits ConfigurationElement
    Implements IRule(Of String)

    Private _DivideTo As Integer
    Public Property DivideTo() As Integer
        Get
            Return _DivideTo
        End Get
        Set(ByVal value As Integer)
            _DivideTo = value
        End Set
    End Property

    Private _AcceptZero As Boolean
    Public Property AcceptZero() As Boolean
        Get
            Return _AcceptZero
        End Get
        Set(ByVal value As Boolean)
            _AcceptZero = value
        End Set
    End Property

    Public Function IsValid(ByVal input As String) As Boolean Implements Global.FM.NetBouncer.IRule(Of String).IsValid

        Dim Param As New BaseParameter(Of String, Integer)(input, RuleSets.IntegerSet)
        If Not Param.IsValid() Then Return False

        'Check if we accept Zero
        If Param.Value = 0 AndAlso Not Me.AcceptZero Then Return False

        'OK to divide perfectly
        Return (Param.Value Mod Me.DivideTo) = 0
    End Function

End Class
